require('dotenv').config()
let baseUrl = ''
switch (process.env.BASE) {
    case 'dev':
        baseUrl = process.env.DEV_BASE_URL
        break;
    case 'production':
        baseUrl = process.env.PROD_BASE_URL
        break;
    case 'uat':
        baseUrl = process.env.UAT_BASE_URL
        break;
    default:
        baseUrl = process.env.PROD_BASE_URL
        break;
}
module.exports = {
    mode: 'universal',
    env: {
        baseUrl: baseUrl,
        nodeEnv: process.env.BASE
    },
    /*
     ** Headers of the page
     */
    head: {
        title: process.env.npm_package_name || '',
        meta: [
            { charset: 'utf-8' },
            { name: 'viewport', content: 'width=device-width, initial-scale=1' },
            { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
        ],
        link: [
            { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
        ],
        script:[{
            type: 'text/javascript',
            src: '/scripts/flexible_css.js'
        }, {
            type: 'text/javascript',
            src: '/scripts/flexible.js'
        }]
    },
    /*
     ** Customize the progress-bar color
     */
    loading: { color: '#fff' },
    /*
     ** Global CSS
     */
    css: [
        'element-ui/lib/theme-chalk/index.css',
        'swiper/swiper.scss',
        '@/assets/scss/app.scss',
    ],
    styleResources: {
        scss: [
            '@/assets/scss/variable.scss',
            '@/assets/scss/_mixin.scss'

        ]
    },
    /*
     ** Plugins to load before mounting the App
     */
    plugins: [
        '@/plugins/app.js',
        '@/plugins/element-ui',
        '@/plugins/vue-inject',
        '@/plugins/axios',
        '@/plugins/filters.js',
        { src: '@/plugins/coreComponents.js', mode: 'client' },
        { src: '@/plugins/vue-awesome-swiper.js', mode: 'client' }
    ],
    /*
     ** 开发时使用的模块
     */
    buildModules: [

    ],
    /*
     ** Nuxt.js modules
     */
    modules: [
        // Doc: https://axios.nuxtjs.org/usage
        '@nuxtjs/axios',
        '@nuxtjs/pwa',
        // Doc: https://github.com/nuxt-community/dotenv-module
        ['@nuxtjs/dotenv'],
        '@nuxtjs/style-resources', ['cookie-universal-nuxt']
    ],
    /*
     ** Axios module configuration
     ** See https://axios.nuxtjs.org/options
     */
    axios: {
        proxy: true,
        credentials: true,
    },
    proxy: {
        '/api/api2': {
            target: 'https://api.kanye.rest',
              // 代理地址
            changeOrigin: true,
            pathRewrite: { '^/api/api2': '' }
        },
        '/api': {
            target: baseUrl,
              // 代理地址
            changeOrigin: true,
            pathRewrite: { '^/api': '/api' }
        }
    },
    /*
     ** Build configuration
     */
    build: {
        transpile: [/^element-ui/],
        /*
         ** You can extend webpack config here
         */
        extend(config, ctx) {}
    }

}